/*

Author   : chaos

FileName : stl_deque.cpp

Date     : 17/08/17 04:20:06

*/
#include <iostream>
#include <iterator>
#include <deque>
using namespace std;

template <class T>
void print (deque<T> & pri_con)
{
    if(pri_con.empty())
        cout << "Container is empty!" << endl;
    else{
        typename deque<T>::iterator i;

        for(i = pri_con.begin(); i != pri_con.end();i++)
        {
            cout << *i << " ";
        }
        cout << endl;
    }
}

int main(int argc ,char *argv[])
{
    deque<int> q;

    cout << "Push back 1, 6 and push front 4 ..." << endl << "q : ";
    q.push_back(1);
    q.push_back(6);
    q.push_back(4);
    print(q);

    cout << "Insert 9 into 2nd element ..." << endl << "q : ";
    q.insert(q.begin() + 1,9);
    print(q);

    cout << "Erase second element ..." << endl << "q : ";
    q.erase(q.begin() + 1);
    print(q);

    cout << "Pop back ..." << endl << "q : ";
    q.pop_back();
    print(q);

    cout << "The Size of deque : " << q.size() << endl;

    cout << "Maximum size : " << q.max_size() << endl;

    cout << "Using another deque to initialize deque ... "
        << endl << "q1 : ";
    deque<int> q1 = q;
    print(q1);

    return 0;
}
